package com.vchello.service.impl.security;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.vchello.bean.security.RoleSecurity;
import com.vchello.dao.security.RoleSecurityDao;
import com.vchello.service.security.RoleSecurityService;
import com.vchello.util.ToolUtil;

/**
 * 
 * @author power
 *
 */
@Service(value = "roleSecurityService")
public class RoleSecurityServiceImpl extends ServiceImpl<RoleSecurityDao, RoleSecurity> implements RoleSecurityService {
	
	@Autowired
	private RoleSecurityDao roleSecurityDao;

	@Override
	public boolean saveAllRoleSecurity(List<RoleSecurity> roleSecuritys) {
		return roleSecurityDao.saveAllRoleSecurity(roleSecuritys);
	}

	@Override
	public boolean deleteRoleSecurity(List<RoleSecurity> roleSecuritys) {
		try {
			if(ToolUtil.isArrayListNotEmpty(roleSecuritys)) {
				for (RoleSecurity roleSecurity : roleSecuritys) {
					roleSecurityDao.deleteRoleSecurity(roleSecurity);
				}
				return true;
			}
		} catch (Exception e) {
			e.printStackTrace();
			return false;
		}
		return false;
	}

	@Override
	public boolean deleteByRoleId(int roleId) {
		return roleSecurityDao.deleteByRoleId(roleId);
	}

}
